<template>
  <page-view :title="title">
    <a-card :bordered="false">
      <detail-list title="个人信息">
        <detail-list-item term="id">{{ data.id }}</detail-list-item>
        <detail-list-item term="姓名">{{ data.name }}</detail-list-item>
        <detail-list-item term="年龄">{{ data.age }}</detail-list-item>
        <detail-list-item term="性别">{{ data.gender === 0 ? '男':'女' }}</detail-list-item>
        <detail-list-item term="证件类型">{{ carTypeFilter(data.carType) }}</detail-list-item>
        <detail-list-item term="证件号">{{ data.carId }}</detail-list-item>
        <detail-list-item term="所属部门">{{ departmentFilter(data.department) }}</detail-list-item>
        <detail-list-item term="职级">{{ nurseLevelFilter(data.level) }}</detail-list-item>
      </detail-list>
      <a-divider style="margin-bottom: 32px"/>
      <a-button style="margin-left: 8px" @click="goBack()">返回</a-button>
    </a-card>
  </page-view>
</template>

<script>
import { STable } from '@/components'
import DetailList from '@/components/tools/DetailList'
import { getNurse } from '../../api/nurse'
import { carTypeFilter, departmentFilter, nurseLevelFilter } from '../../dictionary'

const DetailListItem = DetailList.Item

export default {
  name: 'ShowNurse',
  data () {
    return {
      data: null
    }
  },
  components: {
    DetailList,
    DetailListItem,
    STable
  },
  computed: {
    title () {
      return this.$route.meta.title
    }
  },
  methods: {
    goBack () {
      this.$router.push('/nurse/index')
    },
    carTypeFilter,
    departmentFilter,
    nurseLevelFilter
  },
  created () {
    this.id = this.$route.query.id
    getNurse(this.id).then(res => {
      console.log('nurse', res.result)
      this.data = res.result
    })
  }
}
</script>

<style lang="less" scoped>
  .title {
    color: rgba(0,0,0,.85);
    font-size: 16px;
    font-weight: 500;
    margin-bottom: 16px;
  }
</style>
